import moduleCreator from '../moduleCreator'

import api from '@/api'

const modelName = 'res.partner'

const state = {
  //
}

const mutations = {
  //
}

const actions = {
  async search({ commit, state, dispatch }, payload) {
    return dispatch('_search', {
      ...payload,
      domain: { employee: true },
      fields: {
        name: null
      }
    })
  },
  async browse_one({ commit, state, dispatch }, { id }) {
    return dispatch('_browse_one', {
      id,
      fields: {
        name: null,
        title: null,
        comment: null,
        private_channel_id: null,
        sale_order_template_id: {
          sale_order_template_line_ids: { price_unit: null }
        }
      }
    })
  },

  async channel_get({ commit, state, dispatch }, { id }) {
    const cnl = await api.env('mail.channel').channel_get([id])
    commit('UPDATE_DataDict', { private_channel_id: cnl.id })
    console.log('channel_get ', cnl)
    // return state.dataDict
    return new Promise(resolve => {
      resolve(cnl)
    })
  }
}

export default moduleCreator(modelName, {
  namespaced: true,
  state,
  mutations,
  actions
})
